
using Handday.Erp.Core;
using System.Collections.Generic;
using System.Threading.Tasks;
using Handday.Erp.Transfer.Context;
using Handday.Erp.Transfer.Enum;
using Handday.Erp.Transfer.Models.Corp;
using Dapper;

namespace Handday.Erp.Transfer.Repositories.Impl
{
    /// <summary>
    /// 企业dapper
    /// </summary>
    public class CorpDapperRepository : DapperRepository, ICorpDapperRepository
    {
        /// <summary>
        /// ctor
        /// </summary>
        public CorpDapperRepository(TransferDbContext context) : base(context)
        {
        }

        /// <summary>
        /// erp转换企业列表
        /// </summary>
        /// <param name="featureType">功能类型：0：查询所有</param>
        public async Task<IEnumerable<CorpDto>> GetListAsync(ErpFeatureTypeEnum featureType)
        {
            var sql = $"SELECT `CorpId`,`FeatureType` FROM `corp` {(featureType == ErpFeatureTypeEnum.None ? string.Empty : "WHERE `FeatureType`=1")} ;";
            var list = await DbConnection.QueryAsync<CorpDto>(sql);
            return list;
        }
    }
}